﻿@using MML.Helpers.Knockout;
@model AppSCO.Models.seguridadModel
@{
    Layout = null;
    var ko = Html.CreateKnockoutContext();
}

<!DOCTYPE html>
<html>
<head>
    <link href="../../Content/baseadmin.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/jquery.ui.all.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/demos.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/tabs.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/Shadowbox.css" rel="stylesheet" type="text/css" />
    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script src="~/Scripts/jquery.validate.js"></script>
    <script src="http://jquery.bassistance.de/validate/additional-methods.js"></script>
    <script src="~/Scripts/knockout-2.1.0.js"></script>
    <script src="~/Scripts/knockout-mapping.js"></script>
    <script src="~/Scripts/modernizr-2.5.3.js"></script>
    <script src="~/Scripts/baseCitasOnline.js"></script>
    <script src="~/Scripts/tab.ui.js" type="text/javascript"></script>
    <script src="~/Scripts/jquery.ui.core.js" type="text/javascript"></script>
    <script src="~/Scripts/jquery.ui.widget.js" type="text/javascript"></script>
    <script src="~/Scripts/jquery.ui.datepicker.js" type="text/javascript"></script>
    <script src="~/Scripts/messages_es.js"></script>
    <script src="~/Scripts/Shadowbox.js" type="text/javascript"></script>
    <meta name="viewport" content="width=device-width" />
    <title>ACCESO AL SISTEMA</title>
</head>
<body style="background:#848484;">
    <div>
        <div id="pnAccesoSistema" class="pnLogin">
              <table class="login" data-bind="with: usuario" style="margin-left:auto; margin-right:auto;">
                <tr>
                    <td colspan="2" style="text-align:center;">
                        <img src="../../Images/loginImage.png" style="height:100px; width:450px;" />
                    </td>
                </tr>
                <tr>
                    <td>@Html.LabelFor(c=>c.usuario.USULOG)</td>
                    <td><input type="text" data-bind="value: USULOG" style="width:300px;text-transform:uppercase;" /></td>
                </tr>
                <tr>
                    <td>@Html.LabelFor(c=>c.usuario.USUPAS)</td>
                    <td><input type="password" data-bind="value: USUPAS" style="width:300px;" /></td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align:center;">
                        <button data-bind="click: viewModel.IngresarSistema">INGRESAR AL SISTEMA</button>
                    </td>
                </tr>
              </table>
         </div>
    </div>
</body>
</html>
@ko.Initialize(Model)
<script type="text/javascript">
    var urlAccesoSistema = '@Url.Action("ingresarSistema", "seguridad")';
    var urlPaginaPrincipal = '@Url.Action("principal", "seguridad")';

    $(document).ready(function () {
        $(window).resize(function () {
            $('#pnAccesoSistema').css({
                position: 'absolute',
                left: ($(window).width() - $('#pnAccesoSistema').outerWidth()) / 2,
                top: ($(window).height() - $('#pnAccesoSistema').outerHeight()) / 2
            });
        });
        $(window).resize();
    });

    viewModel.IngresarSistema = function () {
        var param = ko.toJSON(viewModel.usuario);
        $.ajax({
            url: urlAccesoSistema,
            type: "POST",
            async: true,
            data: param,
            contentType: "application/json",
            success: function (result) {
                if (result.acceso == "0") {
                    alert(result.mensaje);
                } else {
                    document.location = urlPaginaPrincipal;
                }
            },
            error: msgError
        });
    }
</script>
@ko.Apply(Model)